package com.zdj.collection;

import lombok.Data;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author zhangdj
 * @date 2021-10-14 12:16:07
 */
public class SetTest {

    @Test
    public void hashSetAdd() {
        HashSet<String> set = new HashSet<>();
        set.add("1");
        set.add("1");
        System.out.println(set);
    }

    @Test
    public void emptyStreamTest() {
        List<Model> list = new ArrayList<>();
        Set<Long> collect = list.stream().map(Model::getId).collect(Collectors.toSet());
        System.out.println(collect.size());
    }

    @Data
    class Model {
        private Long id;

        private String name;
    }
}
